package com.vipbbo.spring.bean.customtag2;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;

public class PhoneBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
	@Override
	protected Class<?> getBeanClass(Element element) {
		return Phone.class;
	}

	@Override
	protected void doParse(Element element, BeanDefinitionBuilder builder) {
		String color = element.getAttribute("color");
		String size = element.getAttribute("size");
		String remark = element.getAttribute("remark");
		if (StringUtils.hasText(color)) {
			builder.addPropertyValue("color",color);
		}
		if (StringUtils.hasText(size)) {
			builder.addPropertyValue("size",size);
		}
		if (StringUtils.hasText(remark)) {
			builder.addPropertyValue("remark",remark);
		}
	}
}
